<?php
/*
 * 进云智能生成平台
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
 */
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'get';
if($_RQ['op']=='get'){
	$return['title']='下单';
	$member=model('core/member')->detail($_SESSION['uid'],array('credit1','credit2','credit3','credit4','credit6','mobile','avatar','realname'));
	$return['post']=array(
		'mobile'=>$member['mobile'],
		'name'=>$member['realname'],
		'payfee'=>$feeset[0]['payfee'],
		'type'=>0,
	);
	$return['member']=$member;
	$return['feeset']=$feeset;
	set_html('title','在线预定');
	exi($return);
}
if($_RQ['op']=='post'){
	//下单
	$post=get_postdata();
	if(!$post['start_city']){
		exi('请输入出发地！','error');
	}
	if(!$post['end_city']){
		exi('请输入目的地！','error');
	}
	if(!$post['mobile']){
		exi('请输入手机号！','error');
	}
	if(!$post['name']){
		exi('请输入真实姓名！','error');
	}
	if(!$post['day']){
		exi('请选择日期！','error');
	}
	$post['day']=strtotime($post['day']);
	if($post['day']<=time()){
		exi('日期不正常！','error');
	}
	$post['day']=date('Y-m-d',$post['day']);
	$data=array(
		'uniacid'=>$_SESSION['uniacid'],
		'mid'=>$_SESSION['uid'],
		'name'=>$post['name'],
		'code'=>$post['code'],
		'mobile'=>$post['mobile'],
		'day'=>$post['day'],
		'start_city'=>$post['start_city'],
		'end_city'=>$post['end_city'],
		'createtime'=>TIMESTAMP,
		'status'=>0,
	);
	$this->insert('order',$data);
	exi('预定成功！');
}
if($_RQ['op']=='payresult'){
	$payresult=$_SESSION['pay_result'];
	if($payresult['status']!=1 && $payresult['pay_type'] !='hdfk'){
		exi('支付失败。','error','jy_feejipiao/order/');
	}
	$order=pdo_get('jy_feejipiao_order',array('id'=>$payresult['id']));
	if($order['ispay'] ==1){
		exi('该订单已经支付！','error','jy_feejipiao/order/');
	}
	if($order['payfee']!=$payresult['fee']){
		exi('支付失败！订单金额不匹配！'.$order['price'].'|'.$payresult['fee'],'error','jy_feejipiao/order/');
	}
	$update=array(
		'paytype'=>$payresult['pay_type'],
		'transid'=>$payresult['transaction_id'],
		'paytime'=>time(),
		'status'=>1,
		'ispay'=>1,
	);
	$this->pdo_update('order',$update,array('id'=>$order['id']));
	exi('提交成功!');
}
?>